package cn.com.scitc.dao;

import cn.com.scitc.db.MyBatisHelper;
import cn.com.scitc.mapper.UserMapper;
import cn.com.scitc.model.User;
import org.apache.ibatis.session.SqlSession;

public class UserDao {

    public User findById(Integer id) {
        try (SqlSession session = MyBatisHelper.getSessionFactory().openSession()) {
            UserMapper mapper = session.getMapper(UserMapper.class);
            return mapper.selectByPrimaryKey(id);
        }
    }

    public User findByLoginId(String loginId) {
        try (SqlSession session = MyBatisHelper.getSessionFactory().openSession()) {
            UserMapper mapper = session.getMapper(UserMapper.class);
            return mapper.selectByLoginId(loginId);
        }
    }
}
